﻿using System.Configuration;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;

namespace SellAndBuy.DistributedServices.IoC
{
    public static class Container
    {
        private static IUnityContainer _current;
 
        public static IUnityContainer Current
        {
            get { return _current; }
        }

        static Container()
        {
            _current = ConfigureContainer();
        }

        private static IUnityContainer ConfigureContainer()
        {
            var unityContainer = ConfigureUnity();

            return unityContainer;
        }

        private static IUnityContainer ConfigureUnity()
        {
            var container = new UnityContainer();

            var section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
            section.Configure(container);

            return container;
        }
    }
}